#include "actorpanel.h"
#include "qpainter.h"

ActorPanel::ActorPanel(QWidget* parent):
    QWidget(parent)
{

}

void ActorPanel::paintEvent(QPaintEvent *event)
{
    int width = this->width();
    int height = this->height();
    QPainter painter(this);
    painter.setRenderHints(QPainter::Antialiasing | QPainter::TextAntialiasing);
    painter.translate(width/2, height/2);
    int side = qMin(width, height);
    painter.scale(side / 100.0, side / 100.0);

    drawBackGround(&painter);

}

void ActorPanel::drawBackGround(QPainter *painter)
{
    painter->save();
    //飞机
    QPixmap pixmap(":/pic/planef.png");
    QRectF target(-225.0, -50.0, 450.0, 100.0);
    QRectF source(0.0, 0.0, pixmap.width(), pixmap.height());
    painter->drawPixmap(target, pixmap,source);

    painter->setPen(Qt::NoPen);
    painter->setBrush(QColor(49,54,62,255));
    //左机翼
    QRectF rectangleL1(-200.0, -15.0, 53.0, 30.0);
    painter->drawRect(rectangleL1);
    QRectF rectangleL2(-147.0, -15.0, 38.0, 30.0);
    painter->drawRect(rectangleL2);
    QRectF rectangleL3(-109.0, -15.0, 28.0, 30.0);
    painter->drawRect(rectangleL3);
    QRectF rectangleL4(-81.0, -15.0, 45.0, 30.0);
    painter->drawRect(rectangleL4);
    //右机翼
    QRectF rectangleR1(200.0-53.0, -15.0, 53.0, 30.0);
    painter->drawRect(rectangleR1);
    QRectF rectangleR2(147.0-38, -15.0, 38.0, 30.0);
    painter->drawRect(rectangleR2);
    QRectF rectangleR3(109.0-28, -15.0, 28.0, 30.0);
    painter->drawRect(rectangleR3);
    QRectF rectangleR4(81.0-45, -15.0, 45.0, 30.0);
    painter->drawRect(rectangleR4);

    painter->restore();
}


